package njust.csc.aeapi.service

import njust.csc.aeapi.utils.QRCodeDecoder
import njust.csc.aeapi.utils.QRCodeGenerator
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Service
import java.nio.file.Path

/**
 * @Author ZhouHang
 * @Date 24/6/14 周五
 * Tutorial: https://www.baeldung.com/kotlin/spring-resttemplate-examples
 */
@Service
class QRCodeService @Autowired constructor(
    private val qrCodeGenerator: QRCodeGenerator,
    private val qrCodeDecoder: QRCodeDecoder,
) {
    fun qrcodeGenerate(data: String, filePath: String) {
        qrCodeGenerator.generateQrCode(data, filePath)
    }

    fun qrcodeGenerate(data: String, filePath: Path) {
        qrCodeGenerator.generateQrCode(data, filePath)
    }

    fun qrcodeDecode(filePath: String): String {
        return qrCodeDecoder.decodeQrCode(filePath)
    }

    fun qrcodeDecode(filePath: Path): String {
        return qrCodeDecoder.decodeQrCode(filePath)
    }
}
